package com.heima.leadnews.admin.controller.v1;


import com.heima.leadnews.admin.service.AdSensitiveService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.sensitive.dto.AdSensitiveDto;
import com.heima.model.sensitive.pojo.AdSensitive;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.POST;

/**
 * 敏感词开发
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api("敏感词开发")
public class AdSensitiveController {

    @Autowired
    AdSensitiveService adSensitiveService;

    /**
     * 分页列表查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("分页列表查询")
    public ResponseResult listSensitive(@RequestBody AdSensitiveDto dto){
        return adSensitiveService.listSensitive(dto);
    }

    /**
     * 新增敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("新增敏感词")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 根据id删除敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    @ApiOperation("根据id删除敏感词")
    public ResponseResult delById(@PathVariable("id") Integer id){
         return adSensitiveService.delById(id);
    }

    /**
     * 修改敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("修改敏感词")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.updateSensitive(adSensitive);
    }


}
